<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="layui/css/layui.css">
    <style type="text/css">
        #bg {
            position: fixed;
            left: 0;
            top: 0;
            height: 50%;
            width: 100%;
            z-index: -1;
            background-color: #009688;
        }

        .container {
            width: 420px;
            height: 320px;
            min-height: 320px;
            max-height: 320px;
            position: absolute;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            margin: auto;
            padding: 20px;
            z-index: 130;
            border-radius: 8px;
            background-color: #fff;
            box-shadow: 0 3px 18px rgba(100, 0, 0, .5);
            font-size: 16px;
        }

        .layui-input {
            border-radius: 5px;
            width: 300px;
            height: 40px;
            font-size: 15px;
        }

        .layui-input {
            border-color: gray;
        }

        .layui-form-item {
            margin-left: -20px;
        }

        #logoid {
            margin-top: 15px;
            padding-left: 180px;
            padding-bottom: 15px;
            color: brown;
        }

        .layui-btn {
            margin-left: -50px;
            border-radius: 5px;
            width: 350px;
            height: 40px;
            font-size: 15px;
        }

        .verity {
            width: 120px;
        }

        .font-set {
            font-size: 13px;
            text-decoration: none;
            margin-left: 120px;
        }

        a:hover {
            text-decoration: underline;
        }

    </style>
</head>
<body>
<div id="bg"></div>
<form class="layui-form" action="" method="post" onsubmit="return false;">
    <div class="container">

        <div class="layui-form-mid layui-word-aux">
            <!--<img id="logoid" src="06.png" height="35">-->
            <h3 id="logoid">用户登录</h3>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">账号</label>
            <div class="layui-input-block">
                <input type="text" name="bankCode" required lay-verify="required|account" placeholder="请输入用户名"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">密码</label>
            <div class="layui-input-inline">
                <input type="password" name="password" required lay-verify="required|password" placeholder="请输入密码"
                       autocomplete="off" class="layui-input">
            </div>
            <!-- <div class="layui-form-mid layui-word-aux">辅助文字</div> -->
        </div>
        <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">验证码</label>-->
        <!--<div class="layui-input-inline">-->
        <!--<input type="text" name="title" required  lay-verify="required" placeholder="请输入验证码" autocomplete="off" class="layui-input verity">-->
        <!--</div>-->
        <!--</div>-->
        <!-- 			  <div class="layui-form-item">
                            <label class="layui-form-label">记住密码</label>
                            <div class="layui-input-block">
                              <input type="checkbox" name="close" lay-skin="switch" lay-text="ON|OFF">
                            </div>
                      </div> -->

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="formDemo">登陆</button>
            </div>
        </div>
        <a href="" class="font-set">忘记密码?</a> <a href="register.html" class="font-set">立即注册</a>
    </div>
</form>
<script type="text/javascript" src="layui/layui.js"></script>
<script type="text/javascript" src="js/jquery-1.12.2.min.js"></script>

<script>
        layui.use(['form', 'layedit', 'laydate'], function () {
            var form = layui.form
                , layer = layui.layer
                , layedit = layui.layedit
                , laydate = layui.laydate;


            //自定义验证规则
            form.verify({
                account: [
                    /^\d{6}$/
                    , '账号格式有误,必须是6位数字'
                ]
                , password: [
                    /^[a-zA-Z0-9]{3,12}$/
                    , '密码必须3到12位，且不能出现空格'
                ]

            });


            //监听提交
            form.on('submit(formDemo)', function (data) {
//                    layer.alert(JSON.stringify(data.field), {
//                        title: '最终的提交信息'
//                    })

            $.ajax({
                type:"POST",
                url:"login.do",
                data:data.field,
                dataType:"json",
                success:function (data) {
                    if(data.code == 1){
                        window.location.href="index.html"
                    }
                }
            })
                return false;
            });

        });

    </script>

</body>
</html>